package com.cxhc.app.api;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.cxhc.system.domain.app.RpCallPolice;
import com.cxhc.system.service.app.IRpCallPoliceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.cxhc.common.core.controller.BaseController;
import com.cxhc.common.core.domain.AjaxResult;
import com.cxhc.common.utils.poi.ExcelUtil;
import com.cxhc.common.core.page.TableDataInfo;

/**
 * 微报警Controller
 * 
 * @author Dhq
 * @date 2024-09-23
 */
@RestController
@RequestMapping("/api/callPolice")
public class ApiRpCallPolice extends BaseController
{
    @Autowired
    private IRpCallPoliceService rpCallPoliceService;

    /**
     * 查询微报警列表
     */
    @GetMapping("/list")
    public TableDataInfo list(RpCallPolice rpCallPolice)
    {
        startPage();
        List<RpCallPolice> list = rpCallPoliceService.selectRpCallPoliceList(rpCallPolice);
        return getDataTable(list);
    }

    /**
     * 导出微报警列表
     */
    @PostMapping("/export")
    public void export(HttpServletResponse response, RpCallPolice rpCallPolice)
    {
        List<RpCallPolice> list = rpCallPoliceService.selectRpCallPoliceList(rpCallPolice);
        ExcelUtil<RpCallPolice> util = new ExcelUtil<RpCallPolice>(RpCallPolice.class);
        util.exportExcel(response, list, "微报警数据");
    }

    /**
     * 获取微报警详细信息
     */
    @GetMapping(value = "/detail/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(rpCallPoliceService.selectRpCallPoliceById(id));
    }

    /**
     * 新增微报警
     */
    @PostMapping("/insert")
    public AjaxResult add(@RequestBody RpCallPolice rpCallPolice)
    {
        return toAjax(rpCallPoliceService.insertRpCallPolice(rpCallPolice));
    }

    /**
     * 修改微报警
     */
    @PostMapping("/update")
    public AjaxResult edit(@RequestBody RpCallPolice rpCallPolice)
    {
        return toAjax(rpCallPoliceService.updateRpCallPolice(rpCallPolice));
    }

    /**
     * 删除微报警
     */
	@GetMapping("/delete/{id}")
    public AjaxResult remove(@PathVariable Long id)
    {
        return toAjax(rpCallPoliceService.deleteRpCallPoliceById(id));
    }
}
